#!/usr/bin/python
# -*- coding: utf-8 -*-
#@author: rui.xu <mrhaigui@gmail.com>
import sqlite3
from datetime import datetime
import time
def initDB(con):
	cur = con.cursor()
	cur.execute("""
		create table admin(
		user varchar(20),
		passwd varchar(256)
		)""")
	cur.execute("""insert into admin values ('daxuxu','kissme')""")
	cur.execute("""
	    create table entries(
	    id integer primary key,
	    title varchar(20) NOT NULL,
	    content text NOT NULL,
	    cateid  int(10) NOT NULL,
	    createdtime datetime NOT NULL,
	    modifiedtime datetime varchar(30)
	    )""")
	c_time = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
	#cur.execute("""insert into entries values (s\'NULL\','test title','test content',1,datetime.now(),NULL)""")
	cur.execute("insert into entries(title,content,cateid,createdtime,modifiedtime) values(?,?,?,?,?)",('test title','test content',3,c_time,c_time))
	con.commit()

if __name__ == '__main__': 
	initDB(sqlite3.connect("blog.db"))

